<div class="pop-title">
	<h2><span style="float:left">注册微博账号</span><span style="float:right;margin-right:10px;cursor:pointer;" id="close-panel">x</span></h2>
</div>
<div class="pop-content">
	<table width="100%" cellspacing="5" cellpadding="0" border="0">
		<tr>
			<td align="right" width="320px"><div class="reg-type">电子邮箱</div></td>
			<td width="200px"><input type="text" id="email" /></td>
			<td align="left"><span id="email-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td align="right"><div class="reg-type">昵称</div></td>
			<td><input type="text" id="nickname" maxlength="6" /></td>
			<td align="left"><span id="nickname-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td align="right"><div class="reg-type">性别</div></td>
			<td>
				<div style="height:30px;line-height:30px">
					<input type="radio"  id="sex" name="sex" checked="checked" value="M" />
					<span style="float:left;">男</span>
					<input style="margin-left:20px" type="radio" id="sex" name="sex" value="F" />
					<span style="float:left">女</span>
				</div>
			 </td>
			<td align="left"><span id="sex-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td align="right"><div class="reg-type">创建密码</div></td>
			<td><input type="password" id="password" /></td>
			<td><span id="password-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td align="right"><div class="reg-type">密码确认</div></td>
			<td><input type="password" id="rpassword" /></td>
			<td><span id="rpassword-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td align="right"><div class="reg-type">验证码</div></td>
			<td>
				<span style="float:left"><input type="text" id="vcode-number" /></span>
				<span style="float:left;margin-top:2px;margin-left:5px;"><img src="?c=reg&m=code" imgsrc="?c=reg&m=code" style="display:inline" id="vcode" /></span>
				<span style="float:left;margin-top:10px;margin-left:10px;"><a href="javascript:void(0)" onclick="changeCode('vcode')">换一换</a></span>
			</td>
			<td width="230px"><span id="vcode-tips" class="pop-tips"></span></td>
		</tr>
		<tr>
			<td colspan="3" align="center"><a id="pop-regbtn" href="javascript:;" onfocus="this.blur()"></a></td>
		</tr>
	</table>
</div>
<script type="text/javascript">

$("#pop-regbtn").bind("click",function(){
	
	var email = $(".pop-content #email").val();
	var password = $(".pop-content #password").val();
	var nickname = $(".pop-content #nickname").val();
	var sex = $(".pop-content #sex:checked").val();
	var rpassword = $(".pop-content #rpassword").val();
	var vcode = $(".pop-content #vcode-number").val();
	if(email == ''){
		$(".pop-content #email-tips").html("请输入常用邮箱！").show();
	}else if(nickname == ''){
		$(".pop-content #nickname-tips").html("请输入昵称！").show();
	}else if(password == ''){
		$(".pop-content #password-tips").html("请输入密码！").show();
	}else if(rpassword == ''){
		$(".pop-content #rpassword-tips").html("请再次输入密码！").show();
	}else if(vcode == ''){
		$(".pop-content #vcode-tips").html("请输入验证码！").show();
	}else if(password != rpassword){
		$(".pop-content #rpassword-tips").html("两次输入密码不一致！").show();
	}else{
		$(this).css({"background-position":"0 -187px"});
		$.post("?c=reg&m=reg",{email:email,nickname:nickname,sex:sex,password:password,rpassword:rpassword,vcode:vcode},function(data){
			if(data == "success"){
				window.top.location.href = "?c=user";
			}else{
				switch(data){
					case 'email_empty':
						$(".pop-content #email-tips").html("请输入常用邮箱！").show();
						$(".pop-content #email").select();
						break;
					case 'email_error':
						$(".pop-content #email-tips").html("邮箱格式不正确！").show();
						$(".pop-content #email").select();
						break;
					case 'email_reged':
						$(".pop-content #email-tips").html("该邮箱已经被注册了！").show();
						$(".pop-content #email").select();
					break;
					case 'nickname_empty':
						$(".pop-content #nickname-tips").html("请输入昵称！").show();
						$(".pop-content #nickname").select();
					break;
					case 'password_empty':
						$(".pop-content #password-tips").html("请输入密码！").show();
						$(".pop-content #password").select();
						break;
					case 'password_not_same':
						$(".pop-content #rpassword-tips").html("两次输入密码不一致！").show();
						$(".pop-content #rpassword").select();
						break;
					case 'vcode_error':
						$(".pop-content #vcode-tips").html("验证码错误！").show();
						$(".pop-content #vcode-number").select();
						break;
					default:
						alert(data);
						break;

				}
				changeCode("vcode");
				$("#pop-regbtn").css({"background-position":"0 0"});
			}
		});
	}
});

$(".pop-content #email").bind("blur",function(){
	if($(this).val() == ''){
		$(".pop-content #email-tips").html("请输入常用邮箱！").show();
	}else{
		$(".pop-content #email-tips").html("").hide();
	}
});
$(".pop-content #nickname").bind("blur",function(){
	if($(this).val() == ''){
		$(".pop-content #nickname-tips").html("请输入昵称！").show();
	}else{
		$(".pop-content #nickname-tips").html("").hide();
	}
});
$(".pop-content #password").bind("blur",function(){
	if($(this).val() == ''){
		$(".pop-content #password-tips").html("请输入密码！").show();
	}else{
		$(".pop-content #password-tips").html("").hide();
	}
});
$(".pop-content #rpassword").bind("blur",function(){
	if($(this).val() == ''){
		$(".pop-content #rpassword-tips").html("请再次输入密码！").show();
	}else if($(this).val() != $(".pop-content #password").val()){
		$(".pop-content #rpassword-tips").html("两次输入密码不一致！").show();
	}else{
		$(".pop-content #rpassword-tips").html("").hide();
	}
});
$(".pop-content #vcode-number").bind("blur",function(){
	if($(this).val() == ''){
		$(".pop-content #vcode-tips").html("请输入验证码！").show();
	}else{
		$(".pop-content #vcode-tips").html("").hide();
	}
		
});

$("#close-panel").bind("click",function(){
	$("#pop_panel").remove();
});
</script>